<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://www.yaodian100.com/jsp/yaodian100" prefix="yaodian100" %>
<%@taglib uri="/WEB-INF/tld/pageutil.tld" prefix="pu"%>
<%@taglib uri="/WEB-INF/tld/pageable.tld" prefix="pageable"%>
<%@taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt-rt"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@page import="com.yaodian100.core.common.utils.ServerValue"%>
<c-rt:set var="midContextPath" value='<%=ServerValue.getMidContextPath()%>'/>
<c-rt:set var="tp" value="${pu:pageableTag('tpp', 2, 1)}"/>
<c-rt:set var="hql">
from BlackList where memberId = ?
</c-rt:set>
<c-rt:set var="params" value="${pu:addToList('paras', param.memberId)}"/>
<c-rt:set var="blackLists" value="${pu:queryByHql(hql, params, tp)}"/>
<s:actionerror />
<s:actionmessage />
<s:fielderror />

<script type="text/javascript" charset="UTF-8" src="/js/jquery-ui-1.7.2.custom.min.js"></script>
<script type="text/javascript">
<!--
	$().ready(function(){
		$("#addBlacklist").click(function(){
			$.getJSON("${midContextPath}/member/blackList!checkBlockStatus.do?type=json", 
					{memberId : $("#memberId").val()}
				,function(blockDataExist){
					if ( blockDataExist == "Y" )
						alert("尚有未解锁状态，请先进行解锁动作");
					else if ( blockDataExist == "N" ){
						openDialog("新增黑名单",$("#blackListDialog").load("${midContextPath}/member/blackList!add.do?memberId=${memberId}"),500,400);
					}
			});
		});
	});
	function updBlackList(memberId,id){
		openDialog("修改黑名单",$("#blackListDialog").load("${midContextPath}/member/blackList!edit.do?memberId=" + memberId + "&blackListId=" + id),500,400);
	}
//-->
</script>
<div class="f-link">
	<a href="#" id="addBlacklist" >新增黑名单</a>
</div>
<p></p>
<table class="tb-1" width="100%">
	<thead>
		<tr>
			<th>#</th>
			<th>等级</th>
			<th>状态</th>
			<th>锁定原因</th>
			<th>锁定日期</th>
			<th>解锁日期</th>
			<th></th>
		</tr>
	</thead>
	<c-rt:choose>
		<c-rt:when test="${not empty blackLists}">
			<tbody>
				<c-rt:forEach items="${blackLists}" var="blackList"
					varStatus="rows_index">
					<tr class="${rows_index.count % 2 == 0 ? 'bg-yl' : ''}">
						<td>${rows_index.count }</td>
						<td>${blackListStatus.options[blackList.blockType].name}</td>
						<td>${memberBlockStatus.options[blackList.blockStatus].name}</td>
						<td><yaodian100:textareaViewer value="${blackList.blockReason}"/></td>
						<td><fmt-rt:formatDate value="${blackList.modifyDate}"
							pattern="yyyy-MM-dd HH:mm" /></td>
						<td><fmt-rt:formatDate value="${blackList.unBlockDate}"
							pattern="yyyy-MM-dd HH:mm" /></td>
						<td>
							<c-rt:if test="${empty blackList.unBlockDate}">
								<a href="#" onclick="updBlackList('${blackList.memberId}','${blackList.id}');">修改</a>
							</c-rt:if>
						</td>
					</tr>
				</c-rt:forEach>
			</tbody>
		</c-rt:when>
		<c-rt:otherwise>
			<tbody>
				<tr class="bg-yl">
					<td colspan="7">查无资料!!</td>
				</tr>
			</tbody>
		</c-rt:otherwise>
	</c-rt:choose>
</table>
<input type="hidden" id="memberId" name="memberId" value="${memberId}"/>
<input type="hidden" id="blackListId" name="blackListId" value="${blackList.id}"/>
<pageable:Pageable url="${midContextPath}/member/blackList!search.do" escapeparams="AJAX,refreshZone" parameter="AJAX=true&refreshZone=tabs-3" formname="NewaBlackListForm" key="tpp"></pageable:Pageable>
<div id="blackListDialog">
</div>
